if (!layui) alert('请先引用layui.js文件!');
layui.config({
    base: (function () {
        var aresExtendsFolder = 'aresExtends',
            aresExtendsPath = document.currentScript ? document.currentScript.src : function () {
                var scripts = document.scripts, src;
                for (var i = 0; i < scripts.length; i++) {
                    if (scripts[i].src.indexOf(aresExtendsFolder) != -1) {
                        src = scripts[i].src;
                        break;
                    }
                }
                return src;
            }();
        if (aresExtendsFolder.indexOf(aresExtendsFolder) == -1) throw new Error('请确认自定义layui模块目录引用是否正确')
        return aresExtendsPath.substring(0, aresExtendsPath.lastIndexOf(aresExtendsFolder) + aresExtendsFolder.length + 1)
    })()
}).extend({
    "BaseApi": "api/BaseApi",
    "apiAuth": "api/auth",
    "apiCommon": "api/common",
    "apiUser": "api/user",
    "apiRole": "api/role",

    "baseUrl": "config/baseUrl",
    "conf": "config/conf",
    "constants": "config/constants",
    "routers": "config/routers",

    "http": "services/http",
    "BaseServices": "services/BaseServices",
    "commonServices": "services/commonServices",
    "authServices": "services/authServices",
    "userServices": "services/userServices",
    "roleServices": "services/roleServices",
    "webSocket": "services/webSocketService",

    "address": "utils/address",
    "widget": "utils/widget",
    "utils": "utils/index",
    "menu": "utils/menu",
    "MD5": "utils/md5",

    "filters": "filters/index",
    "dateFilters": "filters/dateFilters",

    "axios": "plugins/axios",
    "crypto": "plugins/crypto",
    "dayjs": "plugins/dayjs/dayjs.min",
    "EventEmitter": "plugins/EventEmitter",
    "jsCookie": "plugins/jsCookie",
    "_": "plugins/lodash",
    "Mock": "plugins/mock",
    "moment": "plugins/moment",
    "NProgress": "plugins/nprogress/nprogress",
    "printArea": "plugins/jquery.PrintArea",
    "qs": "plugins/qs",
    "store": "plugins/store2",
}).use(['jquery', 'element', 'form', 'utils', 'layer'], function ($) {
    var form = layui.form,
        utils = layui.utils;
    form.verify({
        phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
        email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
        url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
        number: function (v) {
            if (v && isNaN(v)) return "只能填写数字"
        },
        integer: [/^\d*$/, "只能填写整数"],
        date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
        identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"],
        min: utils.minVerify,
        max: utils.maxVerify,
        range: utils.rangeVerify,
        minLength: utils.minLengthVerify,
        maxLength: utils.maxLengthVerify,
        rangeLength: utils.rangeLengthVerify,
        requiredRaido: utils.requiredRaido,
        requiredCheckBox: utils.requiredCheckBox,
        minCheckBox: utils.minCheckBox,
        maxCheckBox: utils.maxCheckBox,
    })
})
